package inutan.game.context;

import inutan.game.entity.id.GameLongIdEntity;
import org.ricks.orm.anno.Column;
import org.ricks.orm.anno.Table;
import org.ricks.orm.repository.UniqueCacheRepository;

import java.util.HashMap;
import java.util.Map;

@Table(name = "game_role_info", repository = UniqueCacheRepository.class)
public class RoleInfo extends GameLongIdEntity<RoleInfo> {

    @Column(columnName = "user_name")
    private String userName;

    @Column
    private int sex;

    @Column
    private int level;

    @Column
    private int exp;

    @Column
    private int gold;

    @Column
    private int diamond;

    @Column
    private int payDiamond;

    //序章进度
    @Column
    private int prelude;

    @Column
    private String greetings;

    @Column(columnName = "create_time")
    private long createTime;

    @Column(columnName = "resource_num")
    private Map<Integer,Integer> resourceNum = new HashMap<>();

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getExp() {
        return exp;
    }

    public void setExp(int exp) {
        this.exp = exp;
    }

    public int getGold() {
        return gold;
    }

    public void setGold(int gold) {
        this.gold = gold;
    }

    public int getDiamond() {
        return diamond;
    }

    public void setDiamond(int diamond) {
        this.diamond = diamond;
    }

    public int getPrelude() {
        return prelude;
    }

    public void setPrelude(int prelude) {
        this.prelude = prelude;
    }

    public String getGreetings() {
        return greetings;
    }

    public void setGreetings(String greetings) {
        this.greetings = greetings;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public int getPayDiamond() {
        return payDiamond;
    }

    public void setPayDiamond(int payDiamond) {
        this.payDiamond = payDiamond;
    }

    public Map<Integer, Integer> getResourceNum() {
        return resourceNum;
    }

    public void setResourceNum(Map<Integer, Integer> resourceNum) {
        this.resourceNum = resourceNum;
    }

    public Integer getResourceNum1(int resourceType){
        return resourceNum.getOrDefault(resourceType,0);
    }

    public void setResourceNum1(int resourceType,int num){
        if(resourceNum.containsKey(resourceType))
            resourceNum.replace(resourceType,num);
        else resourceNum.put(resourceType,num);
    }
}